﻿//********************************************************************************//
//创建日期：<创建日期，2016-10-12>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：托收信息查询
//********************************************************************************//
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS.ChaXunGL
{
    public partial class TuoShouXXCX : BasePage
    {
        #region 属性

        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtGridTab1
        {
            get
            {
                return ViewState["dtGridTab1"] as DataTable;
            }
            set
            {
                ViewState["dtGridTab1"] = value;
            }
        }


        #endregion

        #region 变量

        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
       
        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            this.gvGridTab1.DataSource = this.dtGridTab1;
            this.gvGridTab1.DataBind();

            
        }




        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {
            if ( cmbTuoShou.Text.Trim()!="")
            {
                LoadGridData();
            }
        }


        
        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            int wtype = BusinessTool.WType;
            gvGridTab1.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            //水量年月
            string water_y_m = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();

        }

        /// <summary>
        /// 加载查询数据
        /// </summary>
        private void LoadGridData()
        {
            int type = Convert.ToInt32(cmbTuoShou.Value);
            this.dtGridTab1 = _SpHelper.P_QSCX_TUOSHOUXXCX(2,1, type ,0).Tables[0];
            gvGridTab1.DataSource = this.dtGridTab1;
            gvGridTab1.DataBind();
            if (this.dtGridTab1 != null && this.dtGridTab1.Rows.Count > 0)
            {
                zjl.Text = "共" + this.dtGridTab1.Rows.Count.ToString() + "条";
                gvGridTab1.FocusedRowIndex = 0;
               //加载详细信息
                int bianhao = Convert.ToInt32(this.gvGridTab1.GetRowValues(this.gvGridTab1.FocusedRowIndex, "I_BIANHAO"));
                DataTable dt = _SpHelper.P_QSCX_TUOSHOUXXCX(2, 2, type, bianhao).Tables[0];
                gvGridTab2.DataSource = dt;
                gvGridTab2.DataBind();
            }


        }

        /// <summary>
        /// grid2刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvGridTab2_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            int type = Convert.ToInt32(cmbTuoShou.Value);
            int bianhao = Convert.ToInt32(this.hdCollection.Get("S_BIANHAO"));
            DataTable dt = _SpHelper.P_QSCX_TUOSHOUXXCX(2, 2, type, bianhao).Tables[0];
            gvGridTab2.DataSource = dt;
            gvGridTab2.DataBind();



            ////DataTable dt = _SpHelper.P_QSCX_TUOSHOUXXCX_MX(bianhao).Tables[0];
            //int len = bianhao == "879" ? 2 : 5;
            //DataTable dt = new DataTable();
            //dt.Columns.Add("S_YONGHUH");dt.Columns.Add("S_YONGHUM");
            //dt.Columns.Add("YM");dt.Columns.Add("SL");
            //dt.Columns.Add("JE");dt.Columns.Add("S_YINHANGHM");
            // dt.Columns.Add("S_YINHANGZH");dt.Columns.Add("S_KAIHUYH");
            // string[] arr = { "	5025001", "上海东江实业有限责任公司", "201411", "6046", "12092.00", "上海东江实业有限责任公司", "03880630801006181", "农行青浦支行青东所" };
            // for (int i = 0; i < len; i++)
            // {
            //     DataRow dr = dt.NewRow();
            //     dr["S_YONGHUH"] = arr[0]; dr["S_YONGHUM"] = arr[1];
            //     dr["YM"] = arr[2];dr["SL"] = arr[3];
            //     dr["JE"] = arr[4];dr["S_YINHANGHM"] = arr[5];
            //     dr["S_YINHANGZH"] = arr[6];dr["S_KAIHUYH"] = arr[7];
            //     dt.Rows.Add(dr);
            // }
            //gvGridTab2.DataSource = dt;
            //gvGridTab2.DataBind();
        }
        #endregion

       
    }
}